package xy.customer;

import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import xy.customer.entity.User;

@FeignClient("xy-server")
public interface UserFeignClient {
	
	/*
	 * 必须用这种注解不能用GetMapping注解
	 * @PathVariable必须设置value，不能只用@PathVariable否则报错
	 */
	@RequestMapping(method = RequestMethod.GET, value = "/simple/{id}")
	public User findById(@PathVariable("id") Long id);
	
	/**
	 * 只要参数是复杂对象，即使指定了get方式请求，feign也会依然用Post发起
	 */
	@RequestMapping(method = RequestMethod.POST, value="/user")
	public User postUser(@RequestBody User user);
	
}
